<?php
/**
 * Admin settings
 * @author JMutsaerts
 *
 */
class Setting extends Model
{
	/**
	*
	* @var SettingCategory
	*/
	private $settingCategory;

	/**
	*
	* @return SettingCategory
	*/
	public function getSettingCategory()
	{
		if(!$this->settingCategory)
		{
			$this->settingCategory = new SettingCategory($this->setting_category_id);
		}	
		return $this->settingCategory;
	}

	/**
	 * 
	 * Enter description here ...
	 * @param Setting $name
	 */
	public static function getValue($name)
	{
		$oSetting = self::getByName($name);
		if($oSetting)
		{
			return $oSetting->value;
		}
		return null;
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param Setting $name
	 */
	public static function getByName($name)
	{
		$aSettings = self::getAll(array('name' => $name), null, null, $limit = 1);
		if(count($aSettings))
		{
			$oSetting = $aSettings[0];	
			return $oSetting;
		}
		return null;
	}
}